<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="shortcut icon" th:href="@{/favicon.ico}" type="image/x-icon" />
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/layui.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/view.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/modules/layer/default/layer.css}"/>
    <script type="text/javascript" th:src="@{/js/jquery-3.2.1.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/layui.all.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/layer.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script th:src="@{/js/html5.min.js}"></script>
    <script th:src="@{/js/respond.min.js}"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
          <input class="layui-input" placeholder="开始日" name="start" id="start">
          <input class="layui-input" placeholder="截止日" name="end" id="end">
          <input type="text" name="keyword"  placeholder="请输入项目名" autocomplete="off" class="layui-input">
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <div class="am-input-group am-input-group-sm">
        <span class="x-right" style="line-height:40px" th:text="'共有数据:【' +${count} + '】条'">共有数据：88 条</span>
      </div>

      <table class="layui-table">
        <thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>项目Id</th>
            <th>项目名称</th>
            <th>众筹金额</th>
            <th>用户姓名</th>
            <th>面向人群</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th style="width: 150px;">项目简介</th>
            <th >操作</th>
            </tr>
        </thead>
        <tbody>
          <tr  th:each="crowds:${list}">
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td th:text="${crowds.id}">1</td>
            <td th:onclick="'javascript:look('+${crowds.id}+')'" th:text="${crowds.projectname}">XXX项目</td>
            <td th:text="${crowds.money}">782000元</td>
            <td th:text="${crowds.userId}">王凯平</td>
            <td th:text="${crowds.faceto}">青少年</td>
            <td th:text="${#dates.format(crowds.createtime, 'yyyy-MM-dd hh:mm:ss')}">开始时间</td>
            <td th:text="${#dates.format(crowds.endtime, 'yyyy-MM-dd hh:mm:ss')}">结束时间</td>
            <td th:text="${crowds.projectabstract}" style="width: 150px;">项目简介</td>
            <td class="td-manage">
              <a href="#"><button class="layui-btn layui-btn-danger" th:onclick="'javascript:passGo('+${crowds.id}+')'" > 通过</button></a>
              <!--<a href="#"><button class="layui-btn layui-btn-warm"> 驳回</button></a>-->
            </td>
          </tr>
        </tbody>
      </table>
      <div class="page">
        <div id="pagination"></div>
      </div>

    </div>
    <script th:inline="javascript">
        /*<![CDATA[*/
        var count = [[${count}]];//总记录数
        var curr = [[${curr}]];//当前页
        var contextPath = [[${#request.getContextPath()}]]; //获取当前应用路径
        // var username = [[${keyword}]]
        /*]]>*/


    </script>
    <script type="text/javascript">
        function  passGo(id) {
            console.log(id)
            axios.get('/cfgjht/crowdfunding/pass?crowdId='+id).then(function(res){
                if (res.data=="1"){
                    alert('成功');
                    window.location.href = contextPath + "/crowdfunding/firstList"

                }
                else {
                    alert('失败')
                }

            })
        }
        function look(id){
            console.log(id)
            parent.layer.open({
                type: 2,
                title: 'layer mobile页',
                shadeClose: true,
                shade: 0.8,
                area: ['380px', '90%'],
                content:contextPath+ '/crowdfunding/info?crowdId='+id
            });
        }

        layui.use('laypage', function(){
            var laypage = layui.laypage;

            //执行一个laypage实例
            laypage.render({
                elem: 'pagination' //注意，这里的 data 是 ID，不用加 # 号
                ,count: count //数据总数，从服务端得到
                ,curr: curr
                // ,username: username
                ,limit: 5
                ,jump: function(obj, first){
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    //首次不执行
                    if(!first){
                        // window.location.href = contextPath + "/chat?page=" + (obj.curr) + "&size=" + obj.limit+ "&keyword=" + obj.username
                        window.location.href = contextPath + "/crowdfunding/firstList?page=" + (obj.curr) + "&size=" + obj.limit
                    }
                }
            });
        });
    </script>
  </body>

</html>